set more off

set seed 12262021

*********************
****** ALLIANCES ****
*********************
use "Alliance_RepData.dta", clear

***********************
*** NON-EXCLUSIVE IRREG

tab irregNA_3 solschangeNA_3

***BASE MODELS

**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 time timesquare timecube, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 time timesquare timecube, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean irregNA_3 0
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities--SOLS change
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg



***CONTROL 1 MODELS

**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 regtransNA abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube, robust cluster (atopidphase)
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 regtransNA abscincperch1_10 decthreat1_10 allyCW1 postCW time timesquare timecube, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean regtransNA 0 abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0 irregNA_3 0
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 2 MODELS

**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 regtransNA abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 regtransNB solschangeNB_3 time timesquare timecube, robust cluster (atopidphase)
*note: there are no regtrans in B that lead to violation; Clarify won't work; drop regtrans in B from analysis
estsimp logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3 regtransNA abscincperch1_10 decthreat1_10 allyCW1 postCW mixedalliance nomicoop estmode milinst abscincperch2_10 incthreat2_10 solschangeNB_3 time timesquare timecube, robust cluster (atopidphase)
setx time mean timesquare mean timecube mean regtransNA 0 abscincperch1_10 0 decthreat1_10 0 allyCW1 0 postCW 0  mixedalliance 0 nomicoop 1 estmode 1 milinst 0 abscincperch2_10 0 incthreat2_10 0 solschangeNB_3 0 irregNA_3 0
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr1)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 0
setx dembothNA 0
simqi, prval(1) genpr(pr2)
setx solschangeNA_3 0
setx dembothsolschangeNA_3 0
setx dembothNA 1
simqi, prval(1) genpr(pr3)
setx solschangeNA_3 1
setx dembothsolschangeNA_3 1
setx dembothNA 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-solsch in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg



*******************
*** EXCLUSIVE IRREG
tab  irregNA_3b solschangeNA_3

***BASE MODELS

**Interaction

logit violate solschangeNA_3 dembothNA dembothsolschangeNA_3 irregNA_3b time timesquare timecube, robust cluster (atopidphase)
**irregNA_3b!=0 predicts failure perfectly and is dropped

**no need to run Control 1 & control 2 models


********************************
********* UNGA *****************
********************************
use "UNGA_RepData.dta", clear
tsset ccode year

***********************
*** NON-EXCLUSIVE IRREG

tab solsch irreg

***BASE MODELS

**Interaction

xtreg logvotech solsch##demboth irreg, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]


*** CONTROL 1 MODEL
*Note: this is actually control 2 in the do files

**Interaction

xtreg logvotech solsch##demboth irreg regtrans allyCW CWend abscincperch10 gdpdrop5 logrealGDPpcG, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]


*******************
*** EXCLUSIVE IRREG

tab  irregb solsch

***BASE MODELS

**Interaction

xtreg logvotech solsch##demboth irregb, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]


*** CONTROL 1 MODEL
*Note: this is actually control 2 in the do files

**Interaction

xtreg logvotech solsch##demboth irregb regtrans allyCW CWend abscincperch10 gdpdrop5 logrealGDPpcG, i(ccode) fe robust cluster(ccode)
margins, dydx(solsch) at(demboth==1) at(demboth==0) post
margins, coeflegend
test  _b[1.solsch:1bn._at] =  _b[1.solsch:2._at]


*******************************
********* SANCTIONS ***********
*******************************
use "Sanctions_RepData.dta", clear

tab ssolsch4 sirreg4

***********************
*** NON-EXCLUSIVE IRREG

******** ALL CASES, W/ US

***BASE MODELS

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 monthnum monthnum2 monthnum3, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 monthnum monthnum2 monthnum3, robust cluster(caseid) 

**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 1

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW monthnum monthnum2 monthnum3, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW monthnum monthnum2 monthnum3, robust cluster(caseid) 
**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 sregtrans 0 allyCWA 1 postCW 0 sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 2

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3, robust cluster(caseid) 
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 sregtrans 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0 sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg



******** ALL CASES, NO US

***BASE MODELS

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 

**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 1

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 
**estimated effect for SOLS changes compared to years w/out ldrtrans
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 sregtrans 0 allyCWA 1 postCW 0 sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


*** CONTROL 2

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 
estsimp logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4 abscincperch10A gdpdrop5A sregtrans allyCWA postCW abscincperch10B tregtrans tsolsch4 gdpratio2008 costs high ifthen monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 
setx monthnum mean monthnum2 mean monthnum3 mean abscincperch10A 0 gdpdrop5A 0 sregtrans 0 allyCWA 1 postCW 0 abscincperch10B 0 tregtrans 0 tsolsch4 0 gdpratio2008 mean costs 0 high 0 ifthen 0 sirreg4 0
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr1)
setx ssolsch4 1
setx ssolsch4intb 0
setx sdemmboth 0
simqi, prval(1) genpr(pr2)
setx ssolsch4 0
setx ssolsch4intb 0
setx sdemmboth 1
simqi, prval(1) genpr(pr3)
setx ssolsch4 1
setx ssolsch4intb 1
setx sdemmboth 1
simqi, prval(1) genpr(pr4)
*effect of solsch in nondem
gen rr1= pr2/pr1
sumqi rr1
sumqi rr1, level(90)
*effect of solsch in dem
gen rr2= pr4/pr3
sumqi rr2
sumqi rr2, level(90)
*compare non-ldrtrans in nondem and dem
gen rr3 = pr1/pr3
sumqi rr3
sumqi rr3, level(90)
*compare solsch in nondem and dem
gen rr4= pr2/pr4
sumqi rr4
sumqi rr4, level(90)

* Difference in predicted probabilities
* Democracies
gen ddiff = pr4-pr3
sumqi ddiff
sumqi ddiff, level(90)

* Nondemocracies
gen nddiff = pr2-pr1
sumqi nddiff
sumqi nddiff, level(90)

* Difference between first differences in democracies and nondemocracies
gen marg = nddiff-ddiff
sumqi marg
sumqi marg, level(90)

*Differences in predicted probabilities--contdem
*no SOLS change
gen nsdiff= pr1-pr3
sumqi nsdiff
sumqi nsdiff, level(90)

* SOLS change
gen sdiff= pr2-pr4
sumqi sdiff
sumqi sdiff, level(90)

*Difference between first difference in solschange and no solschange
gen margreg= sdiff-nsdiff
sumqi margreg
sumqi margreg, level (90)

capture drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 pr1 pr2 pr3 pr4 rr1 rr2 rr3 rr4 ddiff nddiff marg nsdiff sdiff margreg


***********************
*** EXCLUSIVE IRREG

tab  sirreg4b ssolsch4

******** ALL CASES, W/ US

**Interaction

logit sendercap2 ssolsch4 sdemmboth ssolsch4intb sirreg4b monthnum monthnum2 monthnum3, robust cluster(caseid) 

**sirreg4b!=0 predicts failure perfectly and is dropped

**no need to estimate Control 1 & Control 2

logit sendercap2 i.ssolsch4##i.sdemmboth sirreg4b monthnum monthnum2 monthnum3, robust cluster(caseid) 
margins, dydx(ssolsch4) at(sdemmboth==1) at(sdemmboth==0) post
margins, coeflegend
test   _b[1.ssolsch4:1bn._at] =   _b[1.ssolsch4:2._at]


******** ALL CASES, NO US

***BASE MODELS

**Interaction

logit sendercap2 i.ssolsch4##i.sdemmboth sirreg4b monthnum monthnum2 monthnum3 if US==0, robust cluster(caseid) 

**sirreg4b!=0 predicts failure perfectly and is dropped

**no need to estimate Control 1 & Control 2


*******************************
********* TRADE  **************
*******************************
use "Trade_RepData.dta", clear
tsset ddyad year

*****RESTRICTED SAMPLE

***********************
*** NON-EXCLUSIVE IRREG

***BASIC

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]


***CONTROL 1

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3 L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3 L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]


***CONTROL 2

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3 L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.regtransB L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3 L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.regtransB L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]



***********************
*** EXCLUSIVE IRREG

tab  irregA_3b solschdumA_3


***BASIC

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]
 

***CONTROL 1

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]


***CONTROL 2

**Interaction

xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.regtransB L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b, fe cluster(ddyad) robust
margins, dydx(L.solschdumA_3) at(L.dembothA==1) at(L.dembothA==0) post
margins, coeflegend
test  _b[1L.solschdumA_3:1bn._at] =  _b[1L.solschdumA_3:2._at]
xtreg MRdv_rest L.solschdumA_3##L.dembothA L.irregA_3b L.regtransA L.allyCW1 L.CWend L.gdpdrop5 L.conflicta L.armconflict L.gattwto L.pta L.solschdumB_3 L.regtransB L.allyCW2 L.conflictb L.gdpln_a L.gdpln_b, fe cluster(ddyad) robust
margins, dydx(L.dembothA) at(L.solschdumA_3==1) at(L.solschdumA_3==0) post
margins, coeflegend
test _b[1L.dembothA:1bn._at] =  _b[1L.dembothA:2._at]

log close
